<template>
	<view>
		<view class="u-m-t-20">
			<view style="display: flex; text-align: center;">
			    <u-form-item class="u-flex u-row-center" label="成功" style="margin-left: 30rpx;" label-width="75">
			    	<u-switch style="margin-top: 20rpx;" size="40" v-model="isAccomplish" />
			    </u-form-item>
			    <u-form-item class="u-flex u-row-center" label="涉及" style="margin-left: 30rpx;" label-width="75">
			    	<u-switch style="margin-top: 20rpx;" size="40" v-model="isInvolve" />
			    </u-form-item>	
				<u-form-item class="u-flex u-row-center">
				    <u-button type="success" size="mini" style="margin-left: 30rpx;" @click="submit">提交</u-button>
				</u-form-item>
			</view>
			<u-cell-group v-if="list.length">
				<u-cell-item v-for="(item,index) in list" :key="index" :title="`编码: ${item.facilityBarcode}`" @click="toQcoefficient(list[index])"></u-cell-item>
			</u-cell-group>
		</view>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
import { accessPersonInfo,maintenancefindGroup } from '../utils/index.js'
	export default {
		data() {
			return {
				isAccomplish:false,
				isInvolve:false,
				labelWidth: 160,		//表单每一项的宽度
				list:[],
				name: ''
			}
		},
		// 进入home页面即获取该用户信息
		async onLoad(options) {
			uni.setNavigationBarTitle({
				title: options.name
			});
			this.name = options.name
			
		},
		methods: {
			async submit(){
				let query = {
					isAccomplish : this.isAccomplish ? 0 : 1,
					isInvolve: this.isInvolve ? 0 : 1,
					type: this.name,
					page: 1,		
					limit: 10000
				}
				const {data} = await maintenancefindGroup(query)
				if(!data.data.list || !data.data.list.length) return this.$refs.uTips.show({
					title: '没有查到数据!',
					type: 'error',
					duration: '2000'
				})
				this.list = data.data.list
				this.$refs.uTips.show({
					title: '查询成功!',
					type: 'success',
					duration: '2000'
				})
			},
			// 品质系数奖励与扣罚记录
			toQcoefficient(item){
				uni.navigateTo({
					url: "../publicPage/setSpotCheck?type=" + item.type
					+ '&facilityBarcode=' + item.facilityBarcode
					+ '&facilityBarcodeType1=' + item.facilityBarcodeType1
					+ '&facilityBarcodeType2=' + item.facilityBarcodeType2
					+ '&facilityName=' + item.facilityName
					+ '&facilityBarcodeType3=' + item.facilityBarcodeType3
					+ '&name=' + this.name
					+ '&timeId=' + item.timeId
				})
			},
		}
	}
</script>

<style lang="scss">
page{
	background-color: #ededed;
}

.camera{
	width: 54px;
	height: 44px;
	
	&:active{
		background-color: #ededed;
	}
}
.user-box{
	background-color: #fff;
}
</style>